package cn.xorange.commons.datasource.constants;


import cn.xorange.commons.utils.configuration.constants.HttpStatus;

/**
 * @author : yangjian
 * @date : 2023/11/22
 */
public enum DataErrorCode {

    DATABASE_RUN_EXCEPTION(HttpStatus.ERROR,1101,"数据库执行异常"),
    DATASOURCE_CHANGE_EXCEPTION(HttpStatus.ERROR,1102,"数据源切换异常"),
    DATASOURCE_NOTFOUND(HttpStatus.ERROR,1103,"没有找到对应数据源:"),
    DATABASE_LINK_FAILURE(HttpStatus.ERROR,1104,"数据库连接失败"),
    IBATIS_BINDING_ERROR(HttpStatus.ERROR,1105,"iBatis binding error"),
    MYBATIS_EXCEPTION(HttpStatus.ERROR,1106,"myBatis exception"),

    SQL_ERROR(HttpStatus.ERROR,1201,"Sql语句出错"),
    SQL_DELETE_NO_WHERE(HttpStatus.ERROR,1202,"没有where不可删除全部数据"),
    SQL_UPDATE_NO_WHERE(HttpStatus.ERROR,1203,"没有where不可修改全部数据"),
    SQL_UPDATE_NO_VALUE_ERROR(HttpStatus.ERROR,1204,"更新没有值，sql错误"),

    ENTITY_KEY_NOT_FOUND(HttpStatus.ERROR,1301,"没有设置主键列"),
    ENTITY_FIELD_NAME_ERROR(HttpStatus.ERROR,1302,"属性名匹配不到错误"),
    ENTITY_BATCH_ADD_ERROR(HttpStatus.ERROR,1303,"实体类批量新增异常"),
    ENTITY_UPDATE_OLD_VALUE_NULL(HttpStatus.ERROR,1304,"未找到需要更新的原数据"),
    ENTITY_NO_VERSION_PROPERTY(HttpStatus.ERROR,1305,"版本控制类没有updateTime属性"),
    ENTITY_RELA_EXCEPTION(HttpStatus.ERROR,1306,"关联实体异常"),



    DATA_UPDATE_NO_CHANGE(HttpStatus.SUCCESS,0,"数据未改变"),
    DATA_VIOLATION_EXCEPTION(HttpStatus.SUCCESS,1402,"SQL参数不符合规范,不能进行处理"),
    DATA_UPDATE_VERSION_OLD(HttpStatus.SUCCESS,1403,"数据已被修改"),
    DATA_KEY_BUILD_FAIL(HttpStatus.ERROR,1404,"序列新增失败"),
    DATA_KEY_VALUE_NULL(HttpStatus.ERROR,1405,"主键值不能为空"),
    DATA_VALUE_NULL(HttpStatus.ERROR,1406,"字段值为空"),
    DATA_LENGTH_ERROR(HttpStatus.ERROR,1407,"字段长度限制错误"),
    DATA_NULL_ERROR(HttpStatus.ERROR,1408,"缺少必填参数"),
    DATA_PARAMS_ERROR(HttpStatus.ERROR,1409,"数据错误"),
    DUPLICATE_KEY_EXCEPTION(HttpStatus.ERROR,1410,"插入数据库失败违反唯一约束"),
    DATA_REPEAT(HttpStatus.ERROR,1411,"已存在相同的"),
    DATA_REPEAT_ANNOTATION_ERROR(HttpStatus.ERROR,1412,"重复列未标明重复条件"),
    DATA_TREE_EXCEPTION(HttpStatus.ERROR,1413,"树类型数据错误"),
    DATA_BAND_EXCEPTION(HttpStatus.ERROR,1414,"数据绑定错误"),
    DATA_COLUMN_NULL(HttpStatus.ERROR,1415,"查询列为空");


    DataErrorCode(int status, int code, String msg){
        this.status = status;
        this.code = code;
        this.msg = msg;
    }

    private int status;
    private int code;
    private String msg;
    public int getStatus(){ return status; }
    public int getCode() {
        return code;
    }
    public String getMsg() {
        return msg;
    }
    public void setStatus(Integer status){
        this.status = status;
    }
    public void setCode(Integer code){
        this.code = code;
    }
    public void setMsg(String msg){
        this.msg = msg;
    }
}
